const Router = require('@koa/router')
const rewire = require('rewire')
const {success, fail} = rewire('./common.cjs')
const mp = rewire('../common/mp.cjs')


const makeRoute = () => {
  const router = new Router()

  router.get('/api', async (ctx, next) => {
    const query = ctx.request.query
    const rs = mp.checkSignature(query)
    if (rs.success) {
      ctx.body = rs.data
    }
    else {
      ctx.body = rs.msg
    }
  })

  router.get('/test', async (ctx, next) => {
    console.log('test')
    ctx.body = 'rrrrrr'
  })

  return router
}


function wxResp(ctx, msg) {
  ctx.body = msg
}

module.exports = {makeRoute}
